/**
 * This class will display a screen summarizing the event or sessional date that 
 * was clicked from the list of items. It contains the date, title and a brief
 * description of the event or deadline.
 * @author Chirag Mistry
 */

package ca.uwo.android.rss.events;

import android.os.Bundle;
import android.text.Html;
import android.text.method.LinkMovementMethod;
import android.text.util.Linkify;
import android.widget.TextView;
import ca.uwo.android.BaseMenuActivity;
import ca.uwo.android.R;

public class DateItemSummary extends BaseMenuActivity {

	public void onCreate(Bundle savedInstanceState) {

		super.onCreate(savedInstanceState);
		setContentView(R.layout.datesfeed_iteminfoscreen); // set layout

		// access the date, title and summary fields from the layout file
		TextView summaryField = (TextView) findViewById(R.id.summary);
		TextView dateField = (TextView) findViewById(R.id.date);
		TextView titleField = (TextView) findViewById(R.id.title);

		// get the date, event and summary for the clicked item
		String date = getIntent().getExtras().getString("DATE");
		String title = getIntent().getExtras().getString("TITLE");
		String summary = getIntent().getExtras().getString("SUMMARY");
		int type = getIntent().getExtras().getInt("TYPE");

		// populate the fields with the information
		dateField.append(date);
		titleField.append(title);

		// convert (for Service Interruptions) any html that has been included
		// in the feed
		summaryField.append(Html.fromHtml(summary));
		summaryField.setMovementMethod(LinkMovementMethod.getInstance());
		
		if (type != RssDatesFeed.SERVICEINTERRUPTIONS && type != RssDatesFeed.ALUMNIEVENTS) {
			
			// linkify the text (i.e. phone numbers, websites, etc.)
			Linkify.addLinks(summaryField, Linkify.WEB_URLS);
		}
	}
}
